<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我发起的审批</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/zc/toastr.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap-table/dist/bootstrap-table.min.css" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/BootStrapUI/plugins/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/BootStrapUI/plugins/font-awesome/css/font-awesome.min.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/bootstrap/js/tests/vendor/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/bootstrap-table/dist/bootstrap-table.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/bootstrap-table/src/locale/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/BootStrapUI/plugins/layui/layui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/zc/toastr.min.js"></script>
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/uploadPreview.js"></script> --%>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/statics/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/statics/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/statics/ueditor/lang/zh-cn/zh-cn.js"></script>
<!-- 表单验证 -->
<script src="${pageContext.request.contextPath}/js/bootstrapValidator.min.js"></script>
<style type="text/css">
	/*初始化编辑器边框*/
	.edui-default .edui-editor {
	    border: 0px solid #d4d4d4;
	}
	/*初始化编辑器高度,默认320*/
	#edui1_iframeholder{
	    height: 60vh !important
	}
	.table_list_box{
   		table-layout:fixed !important;
	}
</style> 
<script type="text/javascript">
    //ueditorUE 初始化文本编辑器
    //var ue = UE.getEditor('content');
    var ue = UE.getEditor('html',{
        //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
        toolbars:[],
        //关闭字数统计
        wordCount:false,
        //默认的编辑区域高度
        initialFrameWidth:null,
        //initialFrameHeight:null,  //初始化编辑器高度,默认320
        //更多其他参数，请参考ueditor.config.js中的配置项
    });
    //ueditorUE 去掉本地保存成功的提示框！
    ue.ready(function () {
        $(".edui-editor-messageholder.edui-default").css({ "visibility": "hidden" });
        ue.setDisabled();
    });
</script>

<script type="text/javascript">
	$(function() {
		/* —————————————————————————— */
		//1.初始化Table
		var oTable = new TableInit();
		oTable.Init();
		//2.初始化Button的点击事件
		var oButtonInit = new ButtonInit();
		//行点击事件
	    $('#tb_departments').on('click-row.bs.table', function (e, row, element) {initBottomTable(row.approvalId, row.status03);});
		oButtonInit.Init();
		// 文件导出
		$("#btn_export").click(
			function() {
				//取表格的选中行数据
				var arrselections = $("#tb_departments").bootstrapTable('getSelections');
				if (arrselections.length <= 0) {
					toastr.warning('请选择有效数据');
					return;
				}
				Ewin.confirm({
					message : "确认要导出选择的数据吗？"
				}).on(
				function(e) {
					if (!e) {
						return;
					}
					$.ajax({
						type : "post",
						url : "#",
						data : {
							"" : JSON.stringify(arrselections)
						},
						success : function(data, status) {
							if (status == "success") {
								toastr.success('导出成功');
								$("#tb_departments").bootstrapTable('refresh');
							}
						},
						error : function() {
							toastr.error('Error');
						},
						complete : function() {
							
						}
					});
				});
			});
			// 点击查询按钮重新刷新该表
			$("#btn_query").click(function() {  
	        	$("#tb_departments").bootstrapTable('refresh');
			});
		});
	
		var TableInit = function() {
		var oTableInit = new Object();
		//初始化Table
		oTableInit.Init = function() {
			$('#tb_departments').bootstrapTable({
				url : '${pageContext.request.contextPath}/approval/approvals.do', //请求后台的URL（*）
				method : 'get', 						//请求方式（*）
				toolbar : '#toolbar', 					//工具按钮用哪个容器
				striped : true, 						//是否显示行间隔色
				cache : false, 							//是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
				pagination : true, 						//是否显示分页（*）
				sortable : false, 						//是否启用排序
				sortOrder : "asc", 						//排序方式
				queryParams : oTableInit.queryParams,	//传递参数（*）
				sidePagination : "server", 				//分页方式：client客户端分页，server服务端分页（*）
				pageNumber : 1, 						//初始化加载第一页，默认第一页
				pageSize : 10, 							//每页的记录行数（*）
				pageList : [10, 20, 30], 				//可供选择的每页的行数（*）
				strictSearch : true,
				clickToSelect : false, 					//是否启用点击选中行
				height : 550, 							//行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
				uniqueId : "approvalId", 						//每一行的唯一标识，一般为主键列
				detailView : false, 					//是否显示父子表
				// smartDisplay : false,
				columns : [ {
                    checkbox: true
                },{
					field : 'approvalId',
					visible : false
				},{
					field : 'applicant',
					align : 'center',
					title : '申请人'
				},{
					field : 'status03',
					align : 'center',
					title : '申请类型'
				}, {
					field : 'approvalTime',
					align : 'center',
					title : '发起时间',
					formatter: function(value, row, index) {
					    return value.substring(0,value.lastIndexOf("."));
					}
				}, {
					field : 'finishTime',
					align : 'center',
					title : '完成时间',
					formatter: function(value, row, index) {
					    return value.substring(0,value.lastIndexOf("."));
					}
				}, {
					field : 'status01',
					align : 'center',
					title : '状态',
					formatter: function (value, row, index) {
						var deptLength = row.status02.split(",").length;
						if (row.status02.indexOf('财务部') != -1) {
							if (deptLength == 2) {
								if (value.indexOf('1') != -1) {
									if (value == 'b1') {
										return '审批通过(已结算)';
									} else {
										return '审批通过';
									}
								}
							}
							if (deptLength == 3) {
								if (value.indexOf('1') != -1) {
									if (value == 'c1') {
										return '审批通过(已结算)';
									} else {
										return '审批通过';
									}
								}
							}
							if (deptLength == 4) {
								if (value.indexOf('1') != -1) {
									if (value == 'd1') {
										return '审批通过(已结算)';
									} else {
										return '审批通过';
									}
								}
							}
							if (value == '0') {
								return '审批中';
							} 
							if (value.indexOf('2') != -1) {
								return '已驳回(已结算)';
							}
						} else {
							if (deptLength == 1) {
								if (value.indexOf('1') != -1) {
									return '审批通过(已结算)';
								} 
							}
							if (deptLength == 2) {
								if (value.indexOf('1') != -1) {
									if (value == 'b1') {
										return '审批通过(已结算)';
									} else {
										return '审批中';
									}
								}
							}
							if (deptLength == 3) {
								if (value.indexOf('1') != -1) {
									if (value == 'c1') {
										return '审批通过(已结算)';
									} else {
										return '审批中';
									}
								}
							}
							if (deptLength == 4) {
								if (value.indexOf('1') != -1) {
									if (value == 'd1') {
										return '审批通过(已结算)';
									} else {
										return '审批中';
									}
								}
							}
							if (value == '0') {
								return '审批中';
							} 
							if (value.indexOf('2') != -1) {
								return '已驳回(已结算)';
							}
						}
                    }
				},{
					field:'title',
	                title:"预览",
	                align:'center',
	                formatter : function(cell, row, index) {
	                	if (row.status03 == '合同协议') {
	                		cell ='<button type="button" id="btn_preview" class="btn btn-primary" onclick="displayPreview('+row.approvalId+')">预览</button>';
		                    return cell;
						} else {
							return '';
						}
	                },
				},{
					field:'title',
	                title:"历史批注",
	                align:'center',
	                formatter : function(value, row, index) {
	                	var cell = '';
	                	var deptLength = row.status02.split(",").length;
	                	var status = row.status01;
						if (deptLength == 1) {
							if (status.indexOf('1') != -1) {
								cell ='<button type="button" class="btn btn-primary" onclick="annotationView('+row.approvalId+')">历史批注</button>';
							}
						}
						if (deptLength == 2) {
							if (status.indexOf('1') != -1) {
								if (status == 'b1') {
									cell ='<button type="button" class="btn btn-primary" onclick="annotationView('+row.approvalId+')">历史批注</button>';
								}
							}
						}
						if (deptLength == 3) {
							if (status.indexOf('1') != -1) {
								if (status == 'c1') {
									cell ='<button type="button" class="btn btn-primary" onclick="annotationView('+row.approvalId+')">历史批注</button>';
								}
							}
						}
						if (deptLength == 4) {
							if (status.indexOf('1') != -1) {
								if (status == 'd1') {
									cell ='<button type="button" class="btn btn-primary" onclick="annotationView('+row.approvalId+')">历史批注</button>';
								}
							}
						}
                    	if (status.indexOf('2') != -1) {
                    		cell ='<button type="button" class="btn btn-primary" onclick="annotationView('+row.approvalId+')">历史批注</button>';
						}
                    	return cell;
	                }
				} ,{
					field:'title',
	                title:"打印",
	                align:'center',
	                formatter : function(cell, row, index) {
	                	if (row.status03 != '合同协议') {
	                		cell ='<button type="button" class="btn btn-primary" onclick="print('+row.approvalId+')">打印</button>';
		                    return cell;
						} else {
							return '';
						}
	                },
				} ,{
					field:'title',
	                title:"附件预览",
	                align:'center',
	                formatter : function(cell, row, index) {
	                	if (row.status03 != '合同协议') {
	                		var val = row.remark06;
							if (val == '') {
								return '';
							} else {
								/* cell ="<button type='button' class='btn btn-primary' onclick='docView(\""+val+"\")'>附件预览</button>"; */
	                			cell = "<a href='${pageContext.request.contextPath}/attachment/"+val+"' target='_blank' class='btn btn-primary'>下载</a>"
								return cell;
							}
						} else {
							return '';
						}
	                },
				}],
			});
		};
		//审批提交成功
		
		//审批提交失败
		
		//得到查询的参数
		oTableInit.queryParams = function(params) {
			var temp = { 
				limit : params.limit, 						// 每页显示多少条
				offset : params.offset/params.limit + 1, 	// 从第几页开始
				startDate : $("#startTime").val(),
				overDate : $("#endTime").val(),
				key01 : $("#type").val(),					// 根据申请类型搜索
			};
			return temp;
		};
		return oTableInit;
	};
	var ButtonInit = function() {
		var oInit = new Object();
		var postdata = {};
		oInit.Init = function() {
			// 初始化页面上面的按钮事件
			// oButtonInit.Init();
		};
		return oInit;
	};
	layui.use([ 'laydate' ], function() {
		var laydate = layui.laydate;
	});
	
	toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
	
	//日期格式化
	function timestampToTime(timestamp) {
		if (timestamp == null) {
			return '';
		} else {
			var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
			Y = date.getFullYear() + '-';
			M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
			D = (date.getDate()+1 < 10 ? '0'+(date.getDate()) : date.getDate());
			return Y+M+D;
		}
	}
	
	// 预览
	function displayPreview(approvalId){
		$.ajax({
            url: '${pageContext.request.contextPath}/approval/queryHTMLByAppId.do' ,
            //dataType: 'json',
            type: 'post',
            data:{"approvalId":approvalId},
            success: function (data) {
            	var jsonObj = eval('(' + data + ')');
            	console.log(jsonObj.html);
                if(jsonObj.html == null){
                    toastr.warning('该内容为空');
                }else{
                    ue.setContent(jsonObj.html);
                    $('#exampleModal').modal(open);
                }
            },
            error: function (data){
            	alert(jsonObj.html)
            }
        });
	}
	
	// 打印
	function print(approvalId){
		 $.ajax({
            url: '${pageContext.request.contextPath}/approval/formPrint.do' ,
            type: 'post',
            async: false,
            dataType: 'json',
            data:{"approvalId":approvalId},
            success: function (data) {
            	console.log(data);
            	$("#t1").html('');
				var row = data.rows;
				console.log(row);
				if (row != undefined) {
					$("#t1").append('<caption>表单信息</caption>');
					for (var i = 0; i < row.length; i++) {
						$("#t1").append(
								'<tr>'
                    			+'<td style="text-align: center;">'+row[i].remark1+'：</td>'
                    			+'<td style="text-align: center;">'+row[i].remark2+'</td>'
                    			+'</tr style="text-align: center;>'
						);
					}
				}
				
				sign(approvalId);
            	$('#my').modal(open);
            }
        }); 
	}
	
	// 签名信息
	function sign(approvalId){
		  $.ajax({
            url: '${pageContext.request.contextPath}/approval/getSign.do' ,
            type: 'post',
            async: false,
            dataType: 'json',
            data:{"approvalId":approvalId},
            success: function (data) {
            	console.log(data);
            	$("#t2").html('');
				var row = data.rows;
				console.log(row);
				if (row != undefined) {
					$("#t2").append('<caption>审批信息</caption>'
							+'<tr>'
							+'<th style="text-align: center;">审批人</th>'
							+'<th style="text-align: center;">审批意见</th>'
							+'<th style="text-align: center;">审批时间</th>'
							+'<th style="text-align: center;">签名信息</th>'
							+'</tr>'
					);
					for (var i = 0; i < row.length; i++) {
						$("#t2").append(
								'<tr>'
                    			+'<td style="text-align: center;">'+row[i].remark4+'</td>'
                    			+'<td style="text-align: center;">'+row[i].remark2+'</td>'
                    			+'<td style="text-align: center;">'+row[i].remark3+'</td>'
                    			+'<td style="text-align: center;"> <img width="120px" height="80px" border="0" src="${pageContext.request.contextPath}/'+row[i].remark1+'"/></td>'
                    			+'</tr>'
						);
					}
				}
            }
        });  
	}
	
	// 附件预览
	function docView(docPath){
		//alert(docPath)
		$.ajax({
            url: '${pageContext.request.contextPath}/approval/docToHtml.do' ,
            type: 'post',
            async: false,
            data:{"docPath":docPath},
            success: function (realPath) {
            	alert("${pageContext.request.contextPath}/attachment/" + realPath.trim());
            	window.open("${pageContext.request.contextPath}/attachment/" + realPath.trim());
            }
        });
	}
	
	//修改附件
	function doUpdate() {
		var row = $.map($("#tb_departments").bootstrapTable('getSelections'),function(row){
			return row ;
		});
		if (row.length == 0) {
			toastr.warning('请至少选择一条数据!');
		} else if (row.length == 1) {
			if ('合同协议' == row[0].status03) {
				toastr.warning('合同协议无附件，请重新选择数据!');
			} else if (row[0].remark06 == '') {
				toastr.warning('未上传附件，请重新选择数据!');
			} else {
				$('#approvalId').val(row[0].approvalId);
				$('#attachmentUpdate').modal(open);
				$('#updateApproval').on('click', function() {
					var attachment = $('#attachment').val();
					if (attachment == '') {
						toastr.warning('请选择附件！');
						return false;
					}
					var form = new FormData(document.getElementById("fm"));
					$.ajax({
						type : "post",
						url : "${pageContext.request.contextPath}/initiateMana/updateApproval.do",
						data : form,
						processData:false,
			            contentType:false,
						success : function(data) {
							if(data) {
								toastr.success('附件保存成功！');
								$("#clean").click();
								setTimeout(function(){  //使用  setTimeout（）方法设定定时3000毫秒
									//关闭模态框
									// 父页面刷新
									window.location.reload();  
								},2000);
							} else {
								toastr.warning('附件保存出现错误！');
							}
						},
						error : function () {
							toastr.error('附件保存失败！');
						}
					});
				})
			}
		} else {
			toastr.warning('每次只能选择一条数据!');
		}
	}
</script>

<script type="text/javascript">
	var bootstrapValidator = $("#fmpackage").data('bootstrapValidator');
	//开启验证
	bootstrapValidator.resetForm();
	//刷新表格
	function refresh(){
	    $("#tb_departments").bootstrapTable("refreshOptions",{pageNumber:1})
	};
	function doPackage() {
		var row = $.map($("#tb_departments").bootstrapTable('getSelections'),function(row){
			return row ;
		});
		
		if (row.length == 0) {
			toastr.warning('请至少选择一条数据!');
		} else {
			$('#package').modal(open);
		}
	}
	
	var addFig = false;
	
	function savePackage() {
		var bootstrapValidator = $("#fmpackage").data('bootstrapValidator');
        //开启验证
        bootstrapValidator.validate();
        if (bootstrapValidator.isValid()){
		
			var row = $.map($("#tb_departments").bootstrapTable('getSelections'),function(row){
				return row ;
			});
			
			var ids="";
	        for(var i=0;i<row.length;i++){
	            if(i==0 || i=="0"){
	                ids+=row[i].approvalId;
	            }else{
	                ids+="-"+row[i].approvalId;
	            }
	        }
	        
	     	// 防止重复提交
	        if(addFig == true){
	            return false;
	        }
	        addFig  =  true;
	        
	        var url = "${pageContext.request.contextPath}/approval/toApprovalPackage/" + ids + ".do";
	        $.post(url, $("#fmpackage").serialize(), function(data) {
	            if (data.code == 1) {
	            	toastr.success('打包成功');
	            	setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
	                    $('#package').modal('hide');
	                    $('#tb_departments').bootstrapTable('refresh');
	                    $("#name").val("");
	                    refresh();
	                    addFig  =  false
	                },1000);
	            } else {
	                toastr.error(data.data);
	                addFig  =  false
	            }
	        });
        }
	}
</script>
</head>
<body>
	<div class="panel-body" style="padding-bottom: 0px;">
		<div class="panel panel-default">
			<div class="panel-heading">查询条件</div>
			<div class="panel-body">
				<form id="formSearch" class="form-horizontal">
					<div class="form-group" style="margin-top: 15px">
                        <label class="control-label col-sm-1" for="txt_search_statu" style="width: 30px;">从</label> 
                        <div class="col-sm-2">
                        	<input type="text" name="startTime" id="startTime" lay-verify="required" placeholder="请选择日期！" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this,istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                        </div>
                        <label class="control-label col-sm-1" for="txt_search_statu"  style="width: 30px;padding-left: 0px;">至</label> 
                        <div class="col-sm-2" style="padding-left: 0px;">
                        	<input type="text" name="endTime" id="endTime" lay-verify="required" placeholder="请选择日期！" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this,istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                        </div>
						<label class="control-label col-sm-1" for="pickDate">申请类型</label>
							<div class="col-sm-2">
								<select class="form-control" lay-verify="required" name="type" id="type" >
								  	<option value="">请选择申请类型</option>
								  	<option value="合同协议">合同协议</option>
								  	<c:forEach items="${modelList }" var="model">
								  		<option value="${model.mName }">${model.mName }</option>
								  	</c:forEach>
								</select> 
							</div>
						<div class="col-sm-1" align="right">
							<button type="button" style="width: 150px;" id="btn_query" class="btn btn-primary">查询</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div id="toolbar" class="btn-group">
			<button id="btn_add" type="button" class="btn btn-default" onclick="doUpdate()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>附件修改
			</button>
			<!-- <button id="btn_add" type="button" class="btn btn-default" onclick="doPackage()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>项目打包
			</button> -->
		</div>
		<table id="tb_departments"></table>
		<div id="myTabContent" class="tab-content">
			<div class="modal-body" id="myDV" style="display: none">
				<div id="toolbar" class="btn-group">
		            <button id="btn_ok" type="button" class="btn btn-default">
		                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>通过
		            </button>
		            <button id="btn_failed" type="button" class="btn btn-default">
		                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>驳回
		            </button>
       			</div>
			</div>
			<div class="tablist show1">
				<div class="modal-body" id="myDV1">
					<table id="tb_departments1"></table>
				</div>
			</div>
		</div>
		<!--    底部详情表格   -->
        <div id="detail" class="bootstrap-table">
        	<div class="fixed-table-container">
        		<div class="fixed-table-header">
        			<table class="table table-hover table-striped">
		        		<thead>
		        			<tr id="thead_tr1">
		        			</tr>
		        		</thead>
		        	</table>
        		</div>
        		<div class="fixed-table-body">
        			<table class="table table-hover table-striped" style="margin-top: -40px;">
		        		<thead>
		        			<tr id="thead_tr2">
		        			</tr>
		        		</thead>
		        		<tbody>
		        			<tr id="tbody_tr">
		        			</tr>
		        		</tbody>
		        	</table>
        		</div>
        	</div>
        </div>
	</div>
	<div class="modal fade bs-example-modal-lg" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    	<div class="modal-dialog modal-lg" role="document">
        	<div class="modal-content">
	            <div class="modal-header">
	                <button type="button" class="close closefm" data-dismiss="modal" aria-label="Close">
	                    <span aria-hidden="true">&times;</span>
	                </button>
	                <h4 class="modal-title" id="exampleModalLabel">
	                    <span style="font-size:13px">预览</span>
	                </h4>
	            </div>
	            <div class="modal-body" >
	                <textarea id="html" name="html"></textarea>
	            </div>
        	</div>
    	</div>
	</div>
	
	<!-- 批注信息  -->
	<div class="modal fade" id="exampleModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
   		<div class="modal-dialog" role="document">
    		<div class="modal-content" style="width: 700px;">
      			<div class="modal-header">
        			<button type="button" class="close closefm" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        			<h4 class="modal-title" id="exampleModalLabel2">
        				<span id="bt" style="font-size:13px">历史批注</span>
        			</h4>
      			</div>
      			<div class="modal-body" id="annotationInfo" style="height: 400px;">
	      		</div>
    		</div>
  		</div>
	</div>
	
	<!-- 附件修改  -->
	<div class="modal fade" id="attachmentUpdate" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
   		<div class="modal-dialog" role="document">
    		<div class="modal-content" style="width: 700px;">
      			<div class="modal-header">
        			<button type="button" class="close closefm" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        			<h4 class="modal-title">
        				<span id="bt" style="font-size:13px">附件修改</span>
        			</h4>
      			</div>
      			<div class="modal-body">
      				<form id="fm" class="form-horizontal">
      					<input type="hidden" id="approvalId" name="approvalId">
	          			<div class="form-group">
	           				 <label class="col-sm-3 control-label">附件:</label>
	            			 <div class="col-sm-7"> 
		            			 <input type="file" id="attachment" name="attachment" accept=".doc,.docx">
	          				</div>
	          			</div>
	          			<div style="text-align: center;width: 100%;">
							<button type="button" class="btn btn-primary" id="updateApproval">保存</button>&nbsp;&nbsp;&nbsp;&nbsp;
							<button type="button" class="btn btn-default closefm" data-dismiss="modal" >关闭</button>
						</div>
      				</form>
	      		</div>
    		</div>
  		</div>
	</div>
	<!-- 审批打包  -->
	<div class="modal fade" id="package" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
   		<div class="modal-dialog" role="document">
    		<div class="modal-content" style="width: 700px;">
      			<div class="modal-header">
        			<button type="button" class="close closefm" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        			<h4 class="modal-title">
        				<span id="bt" style="font-size:13px">审批打包</span>
        			</h4>
      			</div>
      			<div class="modal-body">
	        		<form id="fmpackage" class="form-horizontal">
	          			<div class="form-group">
	           				 <label class="col-sm-3 control-label">项目名称:</label>
	            			 <div class="col-sm-7"> 
								<input type="text" class="form-control" id="name" name="name"  placeholder="请输入项目名称" autocomplete="off">
								<span class="xing"></span>
	          				</div>
	          			</div>
	          			 <div class="modal-footer">
					        <button type="button"  class="btn btn-primary" onclick="savePackage()">打包</button>
                          	<button type="button" class="btn btn-default closefm" data-dismiss="modal" >关闭</button>
                        </div>
	        		</form>
	      		</div>
    		</div>
  		</div>
	</div>
</body>
<script type="text/javascript">
	function annotationView(approvalId) {
		$('#exampleModal2').modal(open);
		$('#annotationInfo').empty();
		jQuery("#annotationInfo").load("${pageContext.request.contextPath}/approval/findAnnotationInfoByID.do?approvalId="+approvalId);
	}
</script>
<script type="text/javascript">
	//底部详情列表初始化
	function initBottomTable(approvalId, status03){
		if ('合同协议' != status03) {
			$.ajax({
	            type: "post",
	            url: "${pageContext.request.contextPath}/initiateMana/findDetailByID.do?approvalId="+approvalId,
	            dataType: "json",
	            success: function(data){
	            	$('#thead_tr1').empty();
					$('#thead_tr2').empty();
					$('#tbody_tr').empty();
	            	var fields = data.mFields.split(',');
					var values = data.mValues.split(',');
					var theadHtml = '';
					var tbodyHtml = '';
					for (var i = 0; i < fields.length; i++) {
						theadHtml = theadHtml + '<th style="text-align: center; " data-field="applicant"><div class="th-inner ">'+
							fields[i] + '</div><div class="fht-cell" style="width: 151px;"></div></th>';
						tbodyHtml = tbodyHtml + '<td style="text-align: center;width: ' + (100/fields.length) + '%;">' + values[i] + '</td>';
					}
					$('#thead_tr1').append(theadHtml);
					$('#thead_tr2').append(theadHtml);
					$('#tbody_tr').append(tbodyHtml);
	            }
	        });
		}
	}
</script>

<div class="modal fade bs-example-modal-lg" id="my" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close closefm" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="exampleModalLabel">
                    <span style="font-size:13px">打印</span>&nbsp;&nbsp;&nbsp;&nbsp;
	                <button type="button" class="btn btn-default" onclick="dy()">
	                    <span class="glyphicon glyphicon-print" aria-hidden="true">
	                </button>
                </h4>
                <script>
                    function dy() {
                    	var printHtml =  document.getElementById("dd").innerHTML
                    	printpage(printHtml)
                    }
                   
                    function printpage(printHtml){    
                    	var wind = window.open("",'newwindow', 'top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no');
                    	wind.document.body.innerHTML = printHtml;
                    	wind.print();
                    	return false; 
                    }
                </script>
                </div>
                <div class="modal-body" id="dd">
                    <table id="t1"  border="1px solid" bordercolor="#ddd" width = "100%" style="border-collapse:collapse;margin-bottom: 20px;  border-collapse: collapse; border-spacing: 0; line-height: 24px; font: 14px Helvetica Neue,Helvetica,PingFang SC,\5FAE\8F6F\96C5\9ED1,Tahoma,Arial,sans-serif;" >
                    </table>
                    <table id="t2"  border="1px solid" bordercolor="#ddd" width = "100%" style="border-collapse:collapse;margin-bottom: 20px;  border-collapse: collapse; border-spacing: 0; line-height: 24px; font: 14px Helvetica Neue,Helvetica,PingFang SC,\5FAE\8F6F\96C5\9ED1,Tahoma,Arial,sans-serif;">
                    </table>
                </div>
           </div>
        </div>
    </div>
    
<script type="text/javascript">
    // 校验
    $(function() {
        $("#fmpackage").bootstrapValidator({
            feedbackIcons : {
                valid : 'glyphicon glyphicon-ok',
                invalid : 'glyphicon glyphicon-remove',
                validating : 'glyphicon glyphicon-refresh'
            },
            fields : {
            	name : {
                    validators : {
                        notEmpty : {
                            message : '项目名称不能为空'
                        },
                    }
                }
            },
        });
    });
</script>
</html>
